import { useEffect } from "react";
import { ConfigProvider, notification } from "antd"
import zhCN from 'antd/es/locale/zh_CN';
import moment from 'moment';
import 'moment/locale/zh-cn';

import routes, { useOnAuth, onBeforeRoute, MapRoutes } from '@routes'
import { FCRouter } from '@fcRouter'
import { getQueryString } from '@commonMethod'

import '@styles/App.less';

moment.locale('zh-cn');

function App() {
  const encryptData = getQueryString('encryptData')
  const partnerCode = getQueryString('partnerCode')

  useEffect(() => {

    // 检测ie浏览器
    if(!!window.ActiveXObject || "ActiveXObject" in window) {
      notification.warning({
        message: '温馨提醒',
        description: '尊敬的用户，检测到您正在使用IE浏览器，为了您能获得更好的用户体验，建议切换到Edge、Chrome浏览器。',
        placement: 'top',
        duration: 8,
      })
    }
  },[])

  return (
    <ConfigProvider locale={zhCN}>
      <FCRouter 
        routes={encryptData && partnerCode ? MapRoutes : routes} 
        onAuth={useOnAuth}
        onBeforeRoute={onBeforeRoute} 
      />
    </ConfigProvider>
  );
}

export default App;
